package top.goldenyear.porpoise.framework.gateway;

import top.goldenyear.porpoise.framework.security.core.filter.AdminAuthFilter;
import top.goldenyear.porpoise.framework.security.core.service.IPermissionService;
import top.goldenyear.porpoise.framework.web.core.filter.AdminExceptionFilter;
import top.goldenyear.porpoise.framework.web.core.filter.PorpoiseWebFilter;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.core.handle.Gateway;

/**
 * @author airhead
 */
@Component
@Mapping("/admin-api/**")
public class AdminGateway extends Gateway {
  @Inject private IPermissionService permissionService;
  @Override
  protected void register() {
    filter(0, new AdminExceptionFilter());
    filter(10, new PorpoiseWebFilter());
    filter(30, new AdminAuthFilter(permissionService));

    // 添加Bean
    addBeans(bw -> "adminApi".equals(bw.tag()));
  }
}
